<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        window.onload = function(){
            showPrivate("小灰");
        }
    </script>
</body>

<script src="./layui2_9/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;
        //监听侧边导航栏的点击事件
        element.on('nav(test)', function (elem) {
            var parentLi = elem.closest('li.layui-nav-item');
            var allNavItems = document.querySelectorAll('.layui-nav-tree.layui-nav li.layui-nav-item');//所有li标签
            // 遍历所有导航项
            allNavItems.forEach(function (item) {
                if (item !== parentLi) {
                    // 关闭其他导航项的子菜单
                    var childMenu = item.querySelector('dl.layui-nav-child');
                    if (childMenu) {
                        // 移除 layui-nav-itemed 类以关闭菜单
                        // item.classList.remove('layui-nav-itemed');
                    }
                }
            });
            // 切换当前点击的导航项的展开/关闭状态
            // parentLi.addClass("layui-nav-itemed");

        });
    });
</script>
<script>

    layui.use([ 'form', 'laydate' ], function() {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;

        //日期
        laydate.render({
            elem : '#date'
        });
        laydate.render({
            elem : '#date1'
        });

        //自定义验证规则
        form.verify({
            account : function(value) {
                if (value.length < 3) {
                    return '账号至少得3个字符啊';
                }
            }
        });

        //监听提交
        form.on('submit(reform)', function(data) {
            /*layer.alert(JSON.stringify(data.field), {
                title : '最终的提交信息'
            })*/
            //return false;
        });
    });

</script>
<script>
    function showPrivate(value) {
        window.sessionStorage.setItem("username",value);
        //iframe层
        layer.open({
            type: 2,
            title: '即时通信',
            shade: 0.6, // 遮罩透明度
            shadeClose: true, // 点击遮罩区域，关闭弹层
            area: ['1000px', '600px'],
            content: 'userTalk.html'
        });
    }
</script>

</html>